Promise.any = function (arr) {
  if (!Array.isArray(arr)){
    throw Error('must be array')
  }
  return new Promise((resolve, reject)=>{
    if (arr.length === 0) return
    let num = 0
    let res = []
    arr.forEach((p,i)=>{
      Promise.resolve(p).then((val)=>{
        resolve(val)
      },(reason)=>{
        res.push(reason)
        num === arr.length && reject(new AggregateError('All promises were rejected'))
      })
    })
  })
}

var obj = {
  name: 'lu-lu',
  age: 21
}

function observer(obj,key,value) {
  Object.defineProperty(obj,key,{
    get(){
      console.log('get',value)
      return value
    },
    set(newVal){
      console.log('newVal',newVal)
      value = newVal
      if (!value) {
        console.log('is delete property')
      }
    }
  })
}
observer(obj,'name',obj.name)

obj.name
obj.name = 'nihao'
delete obj.name
